/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import _examples.PRouteNode;
import _examples.aodvnode;
import _examples.global;
import java.util.Vector;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JSlider;
import jbotsim.Clock;
import jbotsim.Node;
import jbotsim.Topology;
import jbotsim.ui.JViewer;
import jbotsim.Clock;

/**
 *
 * @author vincent
 */
public class simgui extends javax.swing.JFrame {

    /**
     * Creates new form simgui
     */
    private int prnumadd;
    private int brnumadd;
    private int last = -1;
  private int preindex=0;
    public simgui() {
        initComponents();
  jPanel1.setVisible(false);
        // global.jv=new JViewer(global.o);
        //	Node.setModel("default", new PRouteNode());

        TestThread1 sub1 = new TestThread1();

        sub1.start();
        TestThread2 sub2 = new TestThread2();

        sub2.start();
 
 Clock.pause();
  
    }

    public class TestThread1 extends Thread {

        public TestThread1() {
        }

        public void run() {

            if (jTopology2 != null) {

                Node.setModel("default", new PRouteNode());
                jTopology2.settopo(global.o);
                global.jv = new JViewer(jTopology2, false);

                jTopology2.setjv(global.jv);
                global.jv.settopo1(global.o);

                global.jprange = jPanel5;
                jSlider1.setValue((int) Node.getModel("default").getCommunicationRange());
                //  JOptionPane.showInputDialog(Node.getModel("default").getCommunicationRange() );
                jPanel5.updateUI();


            }
        }
    }

    public class TestThread2 extends Thread {

        public TestThread2() {
        }

        public void run() {

            if (jTopology3 != null) {




                Node.setModel("aodv", new aodvnode());
                jTopology3.settopo(global.o2);
                global.jv2 = new JViewer(jTopology3, false);

                jTopology3.setjv(global.jv2);
                global.jv2.settopo1(global.o2);




            }
        }
    }

    public void addtext(int type, String a) {
        if (type == 1) {

            //textprp.append(a);

            // jProgressBar5.setValue(jProgressBar5.getValue()+1);  

        } else {
            //   jProgressBar6.setValue(jProgressBar6.getValue()+1);  

          //  textbrp.append(a);

        }
    }

    public void settext(int type, int num) {
        if (type == 1) {
          //  textprnum.setText(String.valueOf(num));
            // jProgressBar5.setValue(jProgressBar5.getValue()+1);  
            // textprp.append(src+"->"+des+", ");
        } else {
          //  textbrnum.setText(String.valueOf(num));
            //   jProgressBar6.setValue(jProgressBar6.getValue()+1);  
            //textbrp.set(src+"->"+des+", ");
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jToggleButton1 = new javax.swing.JToggleButton();
        jButton14 = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jSlider1 = new javax.swing.JSlider();
        jLabel26 = new javax.swing.JLabel();
        pause = new javax.swing.JToggleButton();
        jSplitPane9 = new javax.swing.JSplitPane();
        jTopology2 = new jbotsim.ui.JTopology();
        jTopology3 = new jbotsim.ui.JTopology();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        texthelloclock = new javax.swing.JTextField();
        textfatherlostt = new javax.swing.JTextField();
        textclockt = new javax.swing.JTextField();
        textpktmaxnum = new javax.swing.JTextField();
        textpktmaxlen = new javax.swing.JTextField();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        textmaxchildnum = new javax.swing.JTextField();
        jButton15 = new javax.swing.JButton();
        jComboBox2 = new javax.swing.JComboBox();
        jButton5 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jLabel27 = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jComboBox3 = new javax.swing.JComboBox();
        jButton8 = new javax.swing.JButton();
        jComboBox4 = new javax.swing.JComboBox();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton16 = new javax.swing.JButton();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 373, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(1200, 700));

        jLabel1.setText("编队类型");

        jList1.setVisibleRowCount(5);
        jScrollPane1.setViewportView(jList1);

        jLabel2.setText("飞行编队");

        jButton1.setText("停止");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("圆形环绕主节点");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("圆形区域随机动");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("跟随主节点平移");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "水平", "蛇形队", "楔队", "十字编队", "V型编队", "方形编队", "箭头编队", "三角编队", "星型编队" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jToggleButton1.setText("允许aodv");
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });

        jButton14.setText("改变队形");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2)
                    .addComponent(jButton1)
                    .addComponent(jButton3)
                    .addComponent(jButton4)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jToggleButton1)
                    .addComponent(jButton14))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(jButton14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToggleButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton4)
                .addContainerGap())
        );

        jSplitPane2.setLeftComponent(jPanel1);

        jPanel8.setLayout(new java.awt.BorderLayout());

        jSlider1.setMaximum(800);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        jLabel26.setText("节点通信范围");

        pause.setText("暂停");
        pause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel26)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 694, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 199, Short.MAX_VALUE)
                .addComponent(pause))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pause)
                    .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.add(jPanel5, java.awt.BorderLayout.NORTH);

        jSplitPane9.setDividerLocation(600);

        javax.swing.GroupLayout jTopology2Layout = new javax.swing.GroupLayout(jTopology2);
        jTopology2.setLayout(jTopology2Layout);
        jTopology2Layout.setHorizontalGroup(
            jTopology2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 599, Short.MAX_VALUE)
        );
        jTopology2Layout.setVerticalGroup(
            jTopology2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 624, Short.MAX_VALUE)
        );

        jSplitPane9.setLeftComponent(jTopology2);

        javax.swing.GroupLayout jTopology3Layout = new javax.swing.GroupLayout(jTopology3);
        jTopology3.setLayout(jTopology3Layout);
        jTopology3Layout.setHorizontalGroup(
            jTopology3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 436, Short.MAX_VALUE)
        );
        jTopology3Layout.setVerticalGroup(
            jTopology3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 624, Short.MAX_VALUE)
        );

        jSplitPane9.setRightComponent(jTopology3);

        jPanel8.add(jSplitPane9, java.awt.BorderLayout.CENTER);

        jSplitPane2.setRightComponent(jPanel8);

        jTabbedPane2.addTab("运行界面", jSplitPane2);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1178, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 671, Short.MAX_VALUE)
        );

        jTabbedPane2.addTab("统计参数", jPanel3);

        jLabel4.setText("hello发送周期（clock单位）");

        jLabel16.setText("父节点和子节点丢失时间（t单位，默认40）");

        jLabel17.setText("每个clock的t时间长度（t单位）");

        jLabel18.setText("每轮数据发送的包最大数目");

        jLabel19.setText("每个数据包的最大容量");

        jLabel20.setText("子节点最大容量（默认是3）");

        jLabel21.setText("编队类型：");

        jButton9.setText("确定");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText("确定");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton11.setText("确定");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("确定");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton13.setText("确定");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton15.setText("确定");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "水平", "蛇形队", "楔队", "十字编队", "V型编队", "方形编队", "箭头编队", "三角编队", "星型编队" }));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        jButton5.setText("确认添加编队");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jList2.setVisibleRowCount(5);
        jScrollPane2.setViewportView(jList2);

        jLabel27.setText("编队任务：");

        jButton6.setText("设定移动目的地");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("改变编队类型");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "水平", "蛇形队", "楔队", "十字编队", "V型编队", "方形编队", "箭头编队", "三角编队", "星型编队" }));
        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });

        jButton8.setText("开始仿真");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jLabel3.setText("发送节点");

        jLabel5.setText("接收节点");

        jLabel6.setText("数据量");

        jButton16.setText("添加数据发送任务");
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jButton16))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel21)
                                            .addComponent(jLabel27))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 524, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(jPanel4Layout.createSequentialGroup()
                                                .addComponent(jLabel3)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel5)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel6)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                                                .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
                                                    .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addGroup(jPanel4Layout.createSequentialGroup()
                                            .addComponent(jLabel20)
                                            .addGap(88, 88, 88)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(textpktmaxnum, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(textpktmaxlen, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(textclockt, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(textfatherlostt, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(textmaxchildnum, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(15, 15, 15)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(jLabel16)
                                                            .addComponent(jLabel17))
                                                        .addGap(89, 89, 89))
                                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                                                        .addComponent(jLabel4)
                                                        .addGap(85, 85, 85)
                                                        .addComponent(texthelloclock, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                .addComponent(jLabel18)
                                                .addComponent(jLabel19))
                                            .addGap(18, 18, 18)
                                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jButton9)
                                                .addComponent(jButton10)
                                                .addComponent(jButton11)
                                                .addComponent(jButton12)))
                                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton8)))
                .addContainerGap(569, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(texthelloclock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton9))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(textfatherlostt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton10))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(textclockt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton11))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(textpktmaxnum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton12))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(textpktmaxlen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton13))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textmaxchildnum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton15)
                    .addComponent(jLabel20))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jButton5)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel27)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addComponent(jButton6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 87, Short.MAX_VALUE)
                .addComponent(jButton8)
                .addGap(20, 20, 20))
        );

        jTabbedPane2.addTab("运行参数", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2, javax.swing.GroupLayout.Alignment.TRAILING)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // 、、水平, 蛇形队, 楔队, 十字编队, V型编队, 方形编队, 箭头编队, 三角编队,星型编队

        String type = jComboBox1.getSelectedItem().toString();
        if (type.matches("水平")) {
            //  JOptionPane.showInputDialog("1");
            global.jv.setteamtye(1);
        } else if (type.matches("蛇形队")) {
            global.jv.setteamtye(2);
            //  JOptionPane.showInputDialog("2");
        } else if (type.matches("楔队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(3);
        } else if (type.matches("十字编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(4);
        } else if (type.matches("V型编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(5);
        } else if (type.matches("方形编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(6);
        } else if (type.matches("箭头编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(7);
        } else if (type.matches("三角编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(8);
        } else if (type.matches("星型编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(9);
        }
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        int i = jList1.getSelectedIndex();    // TODO add your handling code here:
        global.jv.setteammovetype(i, 2);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int i = jList1.getSelectedIndex();    // TODO add your handling code here:
        global.jv.setteammovetype(i, 4);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        int i = jList1.getSelectedIndex();    // TODO add your handling code here:
        global.jv.setteammovetype(i, 3);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        try {
            global.MAXPERSEND = Integer.parseInt(textpktmaxlen.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed

        try {
            global.HELLOTIMER = Integer.parseInt(texthelloclock.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        try {
            global.FATHERLOSTTIMER = Integer.parseInt(textfatherlostt.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        try {
            global.HELLOTIMER = Integer.parseInt(texthelloclock.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        try {
            global.TIMEPERSENDS = Integer.parseInt(textpktmaxnum.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        global.aodv = !global.aodv;
    }//GEN-LAST:event_jToggleButton1ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        // TODO add your handling code here:
        int type = jComboBox1.getSelectedIndex();
        int teamid = jList1.getSelectedIndex();
        type++;

        if (type == 1) {
        } else if (type == 2) {
        } else if (type == 3) {
        } else if (type == 4) {
            global.jv.tocross(0, teamid,0);
        } else if (type == 5) {
            global.jv.toV(0, teamid,0);
        } else if (type == 6) {
            global.jv.toSquare(0, teamid,0);
        } else if (type == 7) {
            global.jv.toArrow(0, teamid,0);
        } else if (type == 8) {
            global.jv.toTri(0, teamid,0);
        } else if (type == 9) {
            global.jv.toStar(0, teamid,0);
        }
      //  global.jv.moveteams1();
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        try {
            global.MAXCHILD = Integer.parseInt(textmaxchildnum.getText());
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
        }        // TODO add your handling code here:
    }//GEN-LAST:event_jButton15ActionPerformed

    private void pauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseActionPerformed
        // TODO add your handling code here:
        ispause=!ispause;
        if(ispause)
        {
            Clock.pause();
            pause.setText("点击运行");
        }
        else
        {
            Clock.resume();
            pause.setText("点击暂停");
        }
    }//GEN-LAST:event_pauseActionPerformed

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
        JSlider src = jSlider1;

        for (Node n : global.jv.jtp.topo.getNodes()) {
            n.setCommunicationRange(src.getValue());
        }
        Node.getModel("default").setCommunicationRange(src.getValue());

        global.jv.jtp.updateUI();
    }//GEN-LAST:event_jSlider1StateChanged

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // TODO add your handling code here:
        
           String type = jComboBox2.getSelectedItem().toString();
        if (type.matches("水平")) {
            //  JOptionPane.showInputDialog("1");
         //   global.jv.setteamtye(1);
        } else if (type.matches("蛇形队")) {
          //  global.jv.setteamtye(2);
            //  JOptionPane.showInputDialog("2");
        } else if (type.matches("楔队")) {
            // JOptionPane.showInputDialog("3");
         //   global.jv.setteamtye(3);
        } else if (type.matches("十字编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(4);
        } else if (type.matches("V型编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(5);
        } else if (type.matches("方形编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(6);
        } else if (type.matches("箭头编队")) {
            // JOptionPane.showInputDialog("3");
         //   global.jv.setteamtye(7);
        } else if (type.matches("三角编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(8);
        } else if (type.matches("星型编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(9);
        }
        
        
        /*
         String type = jComboBox2.getSelectedItem().toString();
        if (type.matches("水平")) {
            //  JOptionPane.showInputDialog("1");
            global.jv.setteamtye(1);
        } else if (type.matches("蛇形队")) {
            global.jv.setteamtye(2);
            //  JOptionPane.showInputDialog("2");
        } else if (type.matches("楔队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(3);
        } else if (type.matches("十字编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(4);
        } else if (type.matches("V型编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(5);
        } else if (type.matches("方形编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(6);
        } else if (type.matches("箭头编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(7);
        } else if (type.matches("三角编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(8);
        } else if (type.matches("星型编队")) {
            // JOptionPane.showInputDialog("3");
            global.jv.setteamtye(9);
        }*/
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        
        addlistitem2();
       
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        int index= jList2.getSelectedIndex();
        if(-1==index)
            return;
        addjob(index,0);
        
        
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        
            String type = jComboBox3.getSelectedItem().toString();
                int index= jList2.getSelectedIndex();
        if (type.matches("水平")) {
            
         
        addjob(index,1);
            
            //  JOptionPane.showInputDialog("1");
         //   global.jv.setteamtye(1);
        } else if (type.matches("蛇形队")) {
                
        addjob(index,2);
          //  global.jv.setteamtye(2);
            //  JOptionPane.showInputDialog("2");
        } else if (type.matches("楔队")) {
            // JOptionPane.showInputDialog("3");
         //   global.jv.setteamtye(3);
               addjob(index,3);
        } else if (type.matches("十字编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(4);
               addjob(index,4);
        } else if (type.matches("V型编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(5);
               addjob(index,5);
        } else if (type.matches("方形编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(6);
               addjob(index,6);
        } else if (type.matches("箭头编队")) {
            // JOptionPane.showInputDialog("3");
         //   global.jv.setteamtye(7);
               addjob(index,7);
        } else if (type.matches("三角编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(8);
               addjob(index,8);
        } else if (type.matches("星型编队")) {
            // JOptionPane.showInputDialog("3");
          //  global.jv.setteamtye(9);
               addjob(index,9);
        }
        
   
        
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        int i=0;
        for(i=0;i<global.jbm.jobvv.size();i++)
        {
      
             global.jbm.donext(i);
        }
        
            Clock.resume();                                 
    }//GEN-LAST:event_jButton8ActionPerformed

    
    private int smac;
     private int rmac;
      private int slen;
    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        // TODO add your handling code here:
         
        	try
					{
                                            smac=Integer.parseInt(jComboBox4.getSelectedItem().toString());
                                            rmac=Integer.parseInt(jComboBox5.getSelectedItem().toString());
                                            int sendindex=-1;
                                            int recvindex=-1;
                                       //     JOptionPane.showInputDialog("+"+textsend1.toString()+"+" );
                                            slen=Integer.parseInt(jTextField1.getText());
                                            int i=0;
                                           int index= jList2.getSelectedIndex();
                                           if(index==-1)
                                           {
                                                 JOptionPane.showInputDialog("请选中一个编队!!!" );
                                                 return;
                                           }
                                             
                                            addjob(index,99);
                                            /*
                                            for(i=0;i<global.jv.node.size();i++)
                                            {
                                                global.jv.node.get(i).setmainframe(this);
                                                if(sendmac==global.jv.node.get(i).getprmac())
                                                {
                                                    sendindex=i;
                                                }
                                                 if(recvmac==global.jv.node.get(i).getprmac())
                                                {
                                                    recvindex=i;
                                                }
                                            }
                                            if(recvindex==-1||sendindex==-1)
                                            {
                                                JOptionPane.showInputDialog("bug!!!" );
                                                return;
                                            }
					 global.jv.node.get(sendindex).begsend(global.jv.node.get(recvindex).getprid(),datalen,global.jv.node.get(recvindex),1,recvindex+1);
                                      global.jv2.nodebr.get(sendindex).begsendbr(recvmac,datalen, global.jv2.nodebr.get(recvindex) ,1);
					*/	// if (! Clock.isRunning())
				// Clock.resume(); 
					}
				catch( NumberFormatException e)
			       {
			          JOptionPane.showInputDialog("exception!!!" );
			       }
        //addjob(0,-1);
    }//GEN-LAST:event_jButton16ActionPerformed

    
   
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(simgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(simgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(simgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(simgui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new simgui().setVisible(true);

            }
        });
    }

    public void processbarchange(int id, int value) {
        // JOptionPane.showInputDialog("process bar id"+id );
        if (id == 1) {
         //   jProgressBar1.setValue(value);
        } else if (id == 2) {
          //  jProgressBar2.setValue(value);
        } else if (id == 3) {
           // jProgressBar3.setValue(value);
        } else if (id == 4) {
          //  jProgressBar4.setValue(value);
        } else if (id == 5) {
           // jProgressBar5.setValue(value);
        }


    }

    public void addlistitem() {




        int type = jComboBox1.getSelectedIndex();

        if (type == 0) {
            defaultListModel.add(listnum, "水平飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 1) {
            defaultListModel.add(listnum, "蛇形飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 2) {
            defaultListModel.add(listnum, "楔队飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 3) {

            defaultListModel.add(listnum, "十字飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 4) {
            defaultListModel.add(listnum, "V型飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 5) {
            defaultListModel.add(listnum, "方形飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 6) {
            defaultListModel.add(listnum, "箭头飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 7) {
            defaultListModel.add(listnum, "三角飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 8) {
            defaultListModel.add(listnum, "星型飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        } else if (type == 9) {
            defaultListModel.add(listnum, "楔队飞行编队" + listnum);
            jList1.setModel(defaultListModel);
        }


        listnum++;
    }

    
    public void addlistitem2() {


        //move
         String  strnum = JOptionPane.showInputDialog("请输入节点个数");
            String  strx = JOptionPane.showInputDialog("请输入首节点坐标X");
            String  stry = JOptionPane.showInputDialog("请输入首节点坐标Y");
            int x,y,num;
              try {
             x= Integer.parseInt(strx);
              y=Integer.parseInt(stry);
              num=Integer.parseInt(strnum);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
            return  ;
        }
              
            
             
     String str=""; 
        int type = jComboBox2.getSelectedIndex();

        if (type == 0) {
            defaultListModel.add(listnum2, "水平飞行编队" + listnum2);
            str="水平飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 1) {
            defaultListModel.add(listnum2, "蛇形飞行编队" + listnum2);
              str="蛇形飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 2) {
            defaultListModel.add(listnum2, "楔队飞行编队" + listnum2);
              str="楔队飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 3) {

            defaultListModel.add(listnum2, "十字飞行编队" + listnum2);
              str="十字飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 4) {
            defaultListModel.add(listnum2, "V型飞行编队" + listnum2);
              str="V型飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 5) {
            defaultListModel.add(listnum2, "方形飞行编队" + listnum2);
              str="方形飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 6) {
            defaultListModel.add(listnum2, "箭头飞行编队" + listnum2);
              str="箭头飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 7) {
            defaultListModel.add(listnum2, "三角飞行编队" + listnum2);
              str="三角飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 8) {
            defaultListModel.add(listnum2, "星型飞行编队" + listnum2);
              str="星型飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        } else if (type == 9) {
            defaultListModel.add(listnum2, "楔队飞行编队" + listnum2);
              str="楔队飞行编队" + listnum2;
            jList2.setModel(defaultListModel);
        }
Vector<job> elem1=new Vector<job>();//一维数组
 
elem1.clear();
global.jbm.jobvv.addElement(elem1);

    job j=new job((double)x,(double)y,type+1,num,0,0,0,0);
          
              global.jbm.jobvv.get(listnum2).add(j);
         
              str=str+"("+(last+1)+","+(last+j.num)+")@("+x+","+y+")";
               
                   global.jv.cx=(int)j.x;
                         global.jv.cy=(int)j.y;
                        
                         
                            global.jv.teamtype=j.type;   
            global.jv.createteam(j.num,listnum2);
          
            
             DefaultListModel mod =(DefaultListModel)jList2.getModel();
             mod.setElementAt(str, listnum2);
             jList2.setModel(mod);
     // setjob(listnum2,0);
        listnum2++;
    }
    
    
    private int addjob(int index,int type)
    {
        if(type==0)
        {
           //move
            String  strx = JOptionPane.showInputDialog("请输入目的地坐标X");
            String  stry = JOptionPane.showInputDialog("请输入目的地坐标Y");
            int x,y;
              try {
             x= Integer.parseInt(strx);
              y=Integer.parseInt(stry);
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    null, " ",
                    " ",
                    JOptionPane.DEFAULT_OPTION);
            return 1;
        }
              
            
              job j=new job((double)x,(double)y,-1,0,0,0,0,0);
          
             global.jbm.jobvv.get(index).add(j);
              String str=(String)jList2.getSelectedValue(); 
              str=str+"->("+x+","+y+")";
              
        
            
             DefaultListModel mod =(DefaultListModel)jList2.getModel();
             mod.setElementAt(str, index);
             jList2.setModel(mod);
        }
        else if(type==99)
        {
            
            
               job j=new job(0,0,99,0,smac,rmac,slen,0);
          
             global.jbm.jobvv.get(index).add(j);
              String str=(String)jList2.getSelectedValue(); 
              str=str+"->("+smac+"=>"+slen+"=>"+rmac+")";
              
        
            
             DefaultListModel mod =(DefaultListModel)jList2.getModel();
             mod.setElementAt(str, index);
             jList2.setModel(mod);
             
             
             /*
            int i;
             for(i=0;i<global.jv.node.size();i++)
                                            {
                                                global.jv.node.get(i).setmainframe(this);
                                                if(sendmac==global.jv.node.get(i).getprmac())
                                                {
                                                    sendindex=i;
                                                }
                                                 if(recvmac==global.jv.node.get(i).getprmac())
                                                {
                                                    recvindex=i;
                                                }
                                            }
                                            if(recvindex==-1||sendindex==-1)
                                            {
                                                JOptionPane.showInputDialog("bug!!!" );
                                                return;
                                            }
					 global.jv.node.get(sendindex).begsend(global.jv.node.get(recvindex).getprid(),datalen,global.jv.node.get(recvindex),1,recvindex+1);
                                      global.jv2.nodebr.get(sendindex).begsendbr(recvmac,datalen, global.jv2.nodebr.get(recvindex) ,1);
            smac=smac;*/
        }
        else  if(type>0)
        {
             job j=new job((double)0,(double)0,type,0,0,0,0,0);
          
              global.jbm.jobvv.get(index).add(j);
              String str=(String)jList2.getSelectedValue();
              String typestr=(String)jComboBox3.getSelectedItem();
              str=str+"->"+typestr;
                DefaultListModel mod =(DefaultListModel)jList2.getModel();
             mod.setElementAt(str, index);
             jList2.setModel(mod);
          // change team type
            
        }
        else
        {
            String strsou=(String)jComboBox4.getSelectedItem();
            String strdes=(String)jComboBox5.getSelectedItem();
         //     job j=new job((double)0,(double)0,type,0);
          
        //      global.jbm.jobvv.get(index).add(j);
        String str=(String)jList2.getSelectedValue();
         //     String typestr=(String)jComboBox3.getSelectedItem();
              str=str+"->"+strsou+"-"+jTextField1.getText()+"-"+strdes;
                DefaultListModel mod =(DefaultListModel)jList2.getModel();
             mod.setElementAt(str, index);
             jList2.setModel(mod);
        }
        return 1;
    }
    private Object makeObj(final String item) {
        return new Object() {
            public String toString() {
                return item;
            }
        };
    }

    
  
    public void addnodemac(int mac) {
        //JOptionPane.showMessageDialog( null,"sample dialog !");
        if (last == mac) {
            return;
        }
        jComboBox5.addItem (makeObj(String.valueOf(mac)));
          jComboBox4.addItem (makeObj(String.valueOf(mac)));
        last = mac;
      //  jComboBoxsend1_1.addItem(makeObj(String.valueOf(mac)));
       // jComboBoxsend1_2.addItem(makeObj(String.valueOf(mac)));
      //  jComboBoxsend2_1.addItem(makeObj(String.valueOf(mac)));
      //  jComboBoxsend2_2.addItem(makeObj(String.valueOf(mac)));
      //  jComboBoxsend3_1.addItem(makeObj(String.valueOf(mac)));
     //   jComboBoxsend3_2.addItem(makeObj(String.valueOf(mac)));
      //  jComboBoxsend4_1.addItem(makeObj(String.valueOf(mac)));
      //  jComboBoxsend4_2.addItem(makeObj(String.valueOf(mac)));
 


    }
    DefaultListModel defaultListModel = new DefaultListModel();
    private int listnum = 0;
   


 
     private int listnum2= 0;
    private boolean ispause=false;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane9;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JToggleButton jToggleButton1;
    private jbotsim.ui.JTopology jTopology2;
    private jbotsim.ui.JTopology jTopology3;
    private javax.swing.JToggleButton pause;
    private javax.swing.JTextField textclockt;
    private javax.swing.JTextField textfatherlostt;
    private javax.swing.JTextField texthelloclock;
    private javax.swing.JTextField textmaxchildnum;
    private javax.swing.JTextField textpktmaxlen;
    private javax.swing.JTextField textpktmaxnum;
    // End of variables declaration//GEN-END:variables
}
